package com.itic.market.system.markettoken.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.itic.appbase.framework.common.constants.DBConst;
import com.itic.appbase.framework.common.service.CrudService;
import com.itic.market.system.markettoken.persistence.dao.MarketTokenDao;
import com.itic.market.system.markettoken.persistence.model.MarketToken;
import com.itic.market.system.markettoken.persistence.model.MarketTokenExample;


@Service
@Transactional
public class MarketTokenService
     extends CrudService<MarketTokenDao,MarketToken,MarketTokenExample> {
    @Autowired
    private MarketTokenDao marketTokenDao;

	public MarketToken getMarketTokenByToken(String token) {
		return marketTokenDao.getMarketTokenByToken(token);
	}

	public String deleteByAccessToken(String token) {
		MarketTokenExample example = new MarketTokenExample();
		example.createCriteria().andAccessTokenEqualTo(token);
		
		MarketToken marketToken = new MarketToken();
		marketToken.setIsEffective(DBConst.FALSE);
	    marketTokenDao.updateByExampleSelective(marketToken, example);
	    return SUCCESS;
	}


}